package com.xzy.generic.plus;

import lombok.Getter;
import lombok.ToString;
import org.springframework.context.ApplicationEvent;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;

/**
 * @author xzy.xiao
 * @date 2023/3/13  15:38
 */
@Getter
@ToString
public class GenericEvent<T> extends ApplicationEvent implements ResolvableTypeProvider {

    /**
     * 事件信息
     */
    private final T eventData;

    public GenericEvent(Object source, T eventData) {
        super(source);
        this.eventData = eventData;
    }

    @Override
    public ResolvableType getResolvableType() {
        return ResolvableType.forClassWithGenerics(this.getClass(), ResolvableType.forClass(this.eventData.getClass()));
    }
}
